package com.zprmb.udzt.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.zprmb.udzt.R;
import com.zprmb.udzt.view.Mywebview;

public class WebViewFragment extends Fragment {
	private Mywebview wv;
	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view=inflater.inflate(R.layout.pager_view_layout, null);
		wv=(Mywebview)view.findViewById(R.id.wv);
		wv.loadUrl("https://www.baidu.com");
		wv.setWebViewClient(new WebViewClient(){
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				// TODO Auto-generated method stub
				if (url.indexOf("http://") == 0 || url.indexOf("https://") == 0) {
					
					
					
					
		            view.loadUrl(url);
				return true;
			}
				return true;
			}
		});
		wv.setWebChromeClient(new WebChromeClient() {
			@Override
			public void onProgressChanged(WebView view, int newProgress) {
				Log.e("进度", newProgress + "");
//				if (newProgress == 100) {
//					if(ld!=null){
//						ld.dismiss();
//					}
//				} else {
//					if (!ld.isShowing()) {
//						ld.show();
//					}
//					
//				}
				   
				super.onProgressChanged(view, newProgress);
			}

		});
		return view;
	}
	public static WebViewFragment newInstance(int position, String string) {
		WebViewFragment uf = new WebViewFragment();
		
		
		return uf;
	}

}
